<?php
/**
 *
 * @author liubao
 * @version 1.0
 */

namespace App\Db;


use App\Db\mysql\Mysql;

class Model extends Mysql
{
    protected $device;

    public function __construct()
    {
        //默认主配置
        $config["driver"] = "mysql";
        $config["host"] = "localhost";
        $config["charset"] = "utf8";
        $config["collation"] = "utf8_general_ci";
        $config["port"] = "3306";
        $config['username'] = "api";
        $config['password'] = "api";
        $config['database'] = "api";
        $config["prefix"] = '';
        $md5 = md5(serialize($config));
        parent::__construct($config, $md5);
    }

    /**
     * @return $this
     */
    public function master()
    {
        $config["driver"] = "mysql";
        $config["host"] = "localhost";
        $config["charset"] = "utf8";
        $config["collation"] = "utf8_general_ci";
        $config["port"] = "3306";
        $config['username'] = "api";
        $config['password'] = "api";
        $config['database'] = "api";
        $config["prefix"] = '';
        return $this->db(md5(serialize($config)), $config);
    }

    /**
     * @return $this
     */
    public function slave1()
    {
        //从配置
        $config["driver"] = "mysql";
        $config["host"] = "localhost";
        $config["charset"] = "utf8";
        $config["collation"] = "utf8_general_ci";
        $config["port"] = "3306";
        $config['username'] = "api";
        $config['password'] = "api";
        $config['database'] = "api";
        $config["prefix"] = '';
        $config["debug"] = true;
        return $this->db(md5(serialize($config)), $config);
    }
}
